
set more off 

*TABLE 1, Frequency table of observer types*
tab obsqualnum2 if obsqualnum2>0&americas==1
tab obsqualnum2 if obsqualnum2>0&europe==1
tab obsqualnum2 if obsqualnum2>0&africa==1
tab obsqualnum2 if obsqualnum2>0&mena==1
tab obsqualnum2 if obsqualnum2>0&asia==1
tab obsqualnum2 if obsqualnum2>0

*TABLE 2, Explaining type and number of organizations*
*Multinomial logit of election observers*
mlogit obsqualnum2 majorfraudlag firstelec oda_ln polity2 polity2_sq cgdp_ln americas europe africa asia observeryrs, cluster(ccode) base(0)
est store mlog1

*TABLE 3, Marginal effects*
mlogit obsqualnum2 i.majorfraudlag i.firstelec oda_ln polity2 polity2_sq cgdp_ln americas europe africa asia observeryrs, cluster(ccode) base(0)
*calculate marginal effects for all varibales 
margins, dydx(*) predict(outcome(1))
margins, dydx(*) predict(outcome(2))
margins, dydx(*) predict(outcome(3))
margins, dydx(*) predict(outcome(4))
margins, at((means) polity2=3 polity2_sq=9) pr(outcome(1))
margins, at((means) polity2=10 polity2_sq=100)pr(outcome(1))
margins, at((means) polity2=3 polity2_sq=9) pr(outcome(2))
margins, at((means) polity2=10 polity2_sq=100)pr(outcome(2))
margins, at((means) polity2=3 polity2_sq=9) pr(outcome(3))
margins, at((means) polity2=10 polity2_sq=100)pr(outcome(3))
margins, at((means) polity2=3 polity2_sq=9) pr(outcome(4))
margins, at((means) polity2=10 polity2_sq=100)pr(outcome(4))

*TABLE 4, post-election outcomes*
*Match on variables significant in logit and multinomial logit models* 
cem majorfraudlag firstelec oda_ln(3) polity2(-7  1 6 10) polity2_sq(-49 1 36 100) cgdp_ln(5) , treatment(obs_dum)
*Logit of protests, no interaction*  
logit protest lowqual  multmixqual singlehighqual multhighqual  majorfraud oppwin  oda_ln americas europe africa asia protestyrs  protspline1 protspline2 protspline3[iweight=cem_weights], cluster(ccode)
est store prot1
*Logit of protests,interacting types of observers with major fraud* 
logit protest lowqual  multmixqual singlehighqual multhighqual  lowqual_fraud multmixqual_fraud singlehighqual_fraud multhighqual_fraud majorfraud oppwin  oda_ln americas europe africa asia protestyrs  protspline1 protspline2 protspline3[iweight=cem_weights], cluster(ccode)
est store prot2
*Logit of repression,no interactions* 
logit repression lowqual  multmixqual singlehighqual multhighqual  majorfraud oppwin  oda_ln americas europe africa asia repressionyrs  repressionspline2 repressionspline3 repressionspline1  [iweight=cem_weights], cluster(ccode)
est store rep1
*Logit of repression,interacting types of observers with major fraud* 
logit repression lowqual  multmixqual singlehighqual multhighqual  lowqual_fraud multmixqual_fraud singlehighqual_fraud multhighqual_fraud majorfraud oppwin  oda_ln americas europe africa asia repressionyrs  repressionspline2 repressionspline3 repressionspline1  [iweight=cem_weights], cluster(ccode)
est store rep2
